<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: gavin
 * Date: 15-3-26
 * Time: 下午11:12
 */
class Ghc extends Foreground_Controller
{
    function __construct()
    {
        parent::__construct();

        $this->load->helper('captcha');
        $this->load->library('pagination');
        $this->load->model('ghc_options_model');
        $this->load->model('ghc_blog_model');

    }

    public function index()
    {
        $this->ghc_options_model->addIndexViews();
        $data['blogs'] = $this->ghc_blog_model->getNewsBlog(5);
        $data['blog'] = $this->ghc_blog_model->getTips(3);
        $this->load->view('index',$data);
        //echo "OK";
    }

    public function link()
    {
        $this->load->view('link');
    }

    public function introduction()
    {
        $this->load->view('introduction');
    }

    public function page($date)
    {
        $data['blog'] = $this->ghc_blog_model->getBlogByDate($date);
        if($data['blog'] != null)
        {
            $this->ghc_blog_model->addViewByDate($date);
            $this->load->view('page',$data);
        }
        else{
            header("location:".SITE_URL.'index.php/ghc');
        }
    }
    public function newsplanning($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/newsplanning/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(2);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,2);


        $this->load->view('newsplanning',$data);
    }

    public function newsalumnus($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/newsalumnus/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(3);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,3);


        $this->load->view('newsalumnus',$data);
    }

    public function newscooperation($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/newscooperation/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(4);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,4);


        $this->load->view('newscooperation',$data);
    }

    public function newsinner($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/newsinner/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(5);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,5);


        $this->load->view('newsinner',$data);
    }

    public function newssuggestion($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/newssuggestion/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(1);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,1);


        $this->load->view('newssuggestion',$data);
    }

    public function planningnation($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/planningnation/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(10);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,10);


        $this->load->view('planningnation',$data);
    }

    public function planningprovince($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/planningprovince/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(11);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,11);


        $this->load->view('planningprovince',$data);
    }

    public function planningschool($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/planningprovince/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(12);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,12);


        $this->load->view('planningschool',$data);
    }

    public function planningreference($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/planningreference/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(13);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,13);


        $this->load->view('planningreference',$data);
    }

    public function reseachsubject($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/reseachsubject/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(14);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,14);


        $this->load->view('reseachsubject',$data);
    }

    public function reseachreference($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/reseachreference/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(15);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,15);


        $this->load->view('reseachreference',$data);
    }

    public function downloadspeak($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/downloadspeak/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(6);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,6);


        $this->load->view('downloadspeak',$data);
    }

    public function downloadpolicy($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/downloadpolicy/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(7);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,7);


        $this->load->view('downloadpolicy',$data);
    }

    public function downloaddata($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/downloadpolicy/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(8);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,8);


        $this->load->view('downloaddata',$data);
    }

    public function downloadothers($offset='')
    {
        #配置分页信息
        $config['base_url'] = SITE_URL.'index.php/ghc/downloadothers/';
        $config['total_rows'] = $this->ghc_blog_model->getNumsBySortid(9);//总数
        $config['per_page'] = 3;
        $config['uri_segment'] = 3;

        #自定义分页链接
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';

        #初始化分页类
        $this->pagination->initialize($config);

        #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config['per_page'];

        $data['blogs'] = $this->ghc_blog_model->listBlogBySortid($limit,$offset,9);


        $this->load->view('downloadothers',$data);
    }

}